package dexter.core.client;

import java.util.Properties;

import dexter.util.PropertiesReader;

public class Tester  {
	
	public static void main(String args[]){
		
		//Read main parameters
		String config="config.properties";
		
		for(int i=0; i<args.length; i+=2){
			if(args[i].equals("-p")){
				config=args[i+1];
			}		
		}	
		System.out.println("Reading config file : "+config);
		Properties props=PropertiesReader.getProperties(config);
		
		int type = Integer.parseInt(props.getProperty("type"));
		
		if (type>0) {
			
			int port = Integer.parseInt(props.getProperty("coord_port"));
			String host = props.getProperty("coord_host");
			
			Client client = null;
			switch(type) {
				case 1 : client = new LocalClient(host, port);
				break;
				case 2 : client = new RemoteClient(host, port);
			}
			
			if (client!=null) {
				try {
				  client.executeTest(props);
				} catch(Exception e) {
					e.printStackTrace();					
				}
			}
		}
		
		System.out.println("Exit");
		System.exit(0);
		
	}
}
